// 引入路由组件
// import myHome from '../pages/home'
import myLogin from '../pages/login'
import myRegister from '../pages/register'
import mySearch from '../pages/search'
import myDetail from '../pages/Detail'
import AddCartSuccess from '../pages/AddCartSuccess'
import shopCart from '../pages/ShopCart'
import Trade from '../pages/Trade'
import Pay from '../pages/Pay'
import PaySuccess from '../pages/PaySuccess'
import Center from '../pages/Center'
// 个人中心的二级路由
import myOrder from '../pages/Center/myOrder'
import orderGroup from '../pages/Center/orderGroup'

export default [
        {
            path:'/center',
            component:Center,
            meta:{show:true},
            children:[
                {
                    path:'myOrder',
                    component:myOrder
                },
                {
                    path:'orderGroup',
                    component:orderGroup
                },
                {
                    path:'/center',
                    redirect:'/center/myOrder'
                }
            ]
        },
        {  
            path:'/paySuccess',
            component:PaySuccess,
            meta:{show:true},
            // 用户要在
            // beforeEnter: (to, from, next) => {
            //     if(from.path == '/pay') {
            //         next()
            //     } else {
            //         next(false)
            //     }
            // }
        },
        {  
            path:'/pay',
            component:Pay,
            meta:{show:true},
            beforeEnter:(to,from,next) => {
                if(from.path == '/trade') {
                    next()
                } else{
                    next(false)
                }
            }
        },
        {  
            path:'/trade',
            component:Trade,
            meta:{show:true},
            beforeEnter: (to, from, next) => {
                if(from.path == '/shopCart') {
                    next()
                } else{
                    next(false)
                }
            }
        },
        {  
            path:'/shopCart',
            component:shopCart,
            meta:{show:true}
        },
        {
            path:'/AddCartSuccess',
            name:'AddCartSuccess',
            component:AddCartSuccess,
            meta:{show:true}
            
        },
        {
            path: '/home',
            // 路由懒加载
            component: ()=>import('@/pages/home'),
            meta:{show:true}

        },
        {
            path: '/login',
            component: ()=>import('@/pages/login'),
            meta:{show:false}

        },
        {
            path: '/register',
            component: myRegister,
            meta:{show:false}
        },
        {
            name:'search',
            path:"/search/:keyword?",
            component:mySearch,
            meta:{show:true}
        },
        {
            path:'*',
            redirect:'/home'
        },
        {
            path:'/detail/:skuId?',
            component:myDetail,
            meta:{show:true}

        }
    
]